export class SystemEvent{
    private static AllEvents :any = {};
    public static registerEvent = (name:string , action : (arg:any)=>void)=>{
        if( !SystemEvent.AllEvents[name] ){
            SystemEvent.AllEvents[name] = [];
        }

        SystemEvent.AllEvents[name].push(action);

    }

    public static raiseEvent = (name:string,arg:any)=>{
        var arr = SystemEvent.AllEvents[name];
        if(!arr)
            return;

        arr.forEach((action:any)=>{
            try {
                action(arg);
            } catch (error) {
                
            }
        });
    }
}